Post

Replies

Boosts

Views

Activity

Reply to 401-Unauthorized developer token in Apple Music API
Hey guys, I had the same trouble and found a way to fix it, so if this thread is still active, here's the solution that worked for me:Step 01. Importing Swift JWT to my projectStep 02. The private key must be inserted as a Multi-Line Literal Content:let privateKey = """ -----BEGIN PRIVATE KEY----- MIvcxFYBNEMwqIF73955MGFSS043MF MRNBGSfgQOgOES24FMDsOSBhN+IFUD FaNFDsNFDF0R09543gsNFSMLFDSOAb -----END PRIVATE KEY----- """Step 03. Generating a 5 months valid JWTlet signer = JWTSigner.es256(privateKey: Data(privateKey.utf8)) let calendar = Calendar.current if let exp = calendar.date(byAdding: .month, value: 5, to: Date()) { let claims = ClaimsStandardJWT(iss: "ABCD1234EF", exp: exp, iat: Date()) let header = Header(kid: "GHIJ5678KL") let myJWT = JWT(header: header, claims: claims) do { let signedJWT = try myJWT.sign(using: signer) print(signedJWT) } catch { print("JWT error: \(error)") } }And that should do the trick.
May ’20